home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / hypercrd / hc2_x / tcprogud.sit / TC Prog Guide / card_29601.txt < prev    next >
Text File  |  1991-02-27  |  3KB  |  114 lines

  1. -- card: 29601 from stack: in
  2. -- bmap block id: 0
  3. -- flags: 0000
  4. -- background id: 4755
  5. -- name: 
  6.  
  7.  
  8. -- part 1 (button)
  9. -- low flags: 00
  10. -- high flags: 0001
  11. -- rect: left=13 top=29 right=57 bottom=351
  12. -- title width / last selected line: 0
  13. -- icon id / first selected line: 0 / 0
  14. -- text alignment: 1
  15. -- font id: 0
  16. -- text size: 12
  17. -- style flags: 0
  18. -- line height: 16
  19. -- part name: New Button
  20.  
  21.  
  22. -- part 2 (field)
  23. -- low flags: 00
  24. -- high flags: 0007
  25. -- rect: left=30 top=76 right=296 bottom=478
  26. -- title width / last selected line: 0
  27. -- icon id / first selected line: 0 / 0
  28. -- text alignment: 0
  29. -- font id: 4
  30. -- text size: 9
  31. -- style flags: 0
  32. -- line height: 12
  33. -- part name: code
  34.  
  35.  
  36. -- part contents for background part 6
  37. ----- text -----
  38. Example of user-defined data types
  39.  
  40. -- part contents for card part 2
  41. ----- text -----
  42. /*
  43. *   FILE:    personnel.c
  44. *   AUTHOR:  R.G.
  45. *   CREATED: June 20, 1990
  46. *   
  47. *   C program illustrating scope and use of user-defined data types.
  48. *
  49. *   PROJECT CONTENTS:
  50. *   personnel.c, ANSI, oops libraries
  51. */
  52.  
  53. # include <stdio.h>   /* declares standard I/O functions */
  54. # include <string.h>  /* declares string handling functions */
  55.  
  56. /******************************************************************
  57. *   Definition of enum day_of_week type (file scope)
  58. ******************************************************************/
  59. enum    day_of_week
  60. {
  61.     Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday 
  62. };
  63.     /* synonym for 'enum day_of_week' is simply 'day_of_week': */
  64. typedef enum day_of_week day_of_week;
  65.  
  66. /******************************************************************
  67. *   Definition of struct personnel_rec type (file scope)
  68. ******************************************************************/
  69. struct    personnel_rec
  70. {
  71.     /* declare types of members, without allocating space yet: */
  72.     char    name[80];     
  73.     day_of_week    days_off[2];   /* member has enum type */
  74.     /* legal circular reference using pointer: */
  75.     struct personnel_rec  *boss; 
  76. };
  77. typedef struct personnel_rec personnel_rec;
  78.  
  79. /******************************************************************
  80. *   main() function
  81. ******************************************************************/
  82. main()
  83. {
  84.     /* allocate two struct variables with block scope: */
  85.     personnel_rec  employee[2];
  86.     
  87.     /* string copy function from standard libraries: */
  88.     strcpy(employee[0].name,"Andrew Lipton");
  89.     employee[0].days_off[0] = Saturday;
  90.     employee[0].days_off[1] = Sunday;
  91.     employee[0].boss = &employee[0];      /* Andy's his own boss! */
  92.  
  93.     strcpy(employee[1].name,"James Nutmeg");
  94.     employee[1].days_off[0] = Sunday;
  95.     employee[1].days_off[1] = Wednesday;
  96.     employee[1].boss = &employee[0];
  97.  
  98.     /* use standard library function printf() for output: */
  99.     printf("First employee: %s and his boss: %s\n",
  100.            employee[0].name,(employee[0].boss)->name);
  101.     printf("Second employee: %s and his boss: %s\n",
  102.            employee[1].name,(employee[1].boss)->name);
  103. }
  104.  
  105.  
  106.  
  107.  
  108. -- part contents for background part 4
  109. ----- text -----
  110. This is a complete example demonstrating C data types:
  111.  
  112. -- part contents for background part 7
  113. ----- text -----
  114. 82